package cc.mycraft;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

import cc.mycraft.manager.LoggerListener;
import cc.mycraft.manager.PlayerLogWriter;

public class MYCLog extends JavaPlugin{
	
	private static final String Ver = "20200202";
	public static MYCLog main;
	
	public static MYCLog getInstance() {
		return main;
	}
	
	@Override
	public void onEnable() {
		main = this;
		Bukkit.getLogger().info("\n##################################################\n     MyCraft Log Ver."+Ver+" Made by Gloried");
		PlayerLogWriter.run();
		getServer().getPluginManager().registerEvents(new LoggerListener(), this);
		Bukkit.getLogger().info("Loading Complete!\n##################################################");
		super.onEnable();
	}

	@Override
	public void onDisable() {
		PlayerLogWriter.writeAllLogs();
		super.onDisable();
	}
	
	public boolean onCommand(CommandSender s, Command cmd, String label, String[] args) {
		label = label.toLowerCase();
		switch (label) {
		case "savelog":	PlayerLogWriter.saveLog();return true;
		case "showbukkit": PlayerLogWriter.showBukkit = !PlayerLogWriter.showBukkit;Bukkit.getLogger().info("ShowBukkit="+PlayerLogWriter.showBukkit);;return true;
		default: return true;
		}
	}
	
	
	
}

